package com.stream.cloud.web;

import com.stream.cloud.model.UserEntity;
import com.stream.cloud.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by yebaokang on 2017/11/3.
 */

@RestController

@Slf4j
public class UserController {

    @Autowired
    private UserService userService;

    @Autowired
    private DiscoveryClient discoveryClient;

    @RequestMapping(value="/users")
    public ResponseEntity<List<UserEntity>> readUserInfo() {
        log.info("discoveryClient:" + discoveryClient.getServices());
        log.info("+++++++++ JRebelHello ++++++++++++++");

        List<UserEntity> users = userService.searchAll();
//        List<UserEntity> users = userService.queryAll();
        System.out.println("test ...");
        if (true) {
            System.out.println("teue");
        }
        return new ResponseEntity<List<UserEntity>>(users, HttpStatus.OK);
    }

}

